import java.util.Scanner;
public class huixingshu {
    public static void main(String[] args) {
        int num = 1;
        int k = 0;
        Scanner scan = new Scanner(System.in);
        System.out.println("输入层数");
        int x =scan.nextInt();
        int arr[][] = new int[x][x];
        for (int n = 1; n<=(x/2)+1; n++) {
            for (int j = k; j < x - k; j++) {
                arr[k][j] = num;
                num++;
            }
            for (int i = k + 1; i < x - k; i++) {
                arr[i][x - k - 1] = num;
                num++;
            }
            for (int j = x - k -2; j >k-1; j--) {
                arr[x - k -1][j] = num;
                num++;
            }
            for (int i = x - k - 2; i >=k + 1; i--) {
                arr[i][k] = num;
                num++;
            }
            k++;
        }
        for(int i = 0; i<=x-1;i++){
            for(int j = 0;j<=x-1;j++){
                    if(arr[i][j]<=x) {
                        System.out.print(arr[i][j] + " " + " "+" ");
                    }else{
                        System.out.print(arr[i][j] + " " + " ");
                    }
            }
            System.out.println();
        }
    }
    }

